'use strict';

describe('Filter: elide', function() {

  // load the filter's module
  beforeEach(module('webappApp'));

  // initialize a new instance of the filter before each test
  var elide;
  beforeEach(inject(function($filter) {
    elide = $filter('elide');
  }));

  it('should trim a string to its input length and append "..."', function() {
    expect(elide('1234567890', 5)).toBe('12345...');
  });

  it('should not append "..." if the length is less than the maxLength', function () {
    expect(elide('1234567890', 11)).toBe('1234567890');
  });

  it('should work without a maxLength argument', function () {
    expect(elide('123456789009876543211234567890').length).toBeLessThan(30);
  });

  it('should not append ... to an empty string', function() {
    expect(elide('')).toBe('');
  });

  it('should accept null values and return the empty string', function () {
    expect(elide(undefined)).toBe('');
  });

  it('should trim any leading or trailing spaces before appending the "..."', function () {
    expect(elide(' 1234567890 ', 5)).toBe('12345...');
  });
});